import 'package:flutter/material.dart';

import 'pages/BottomTabs.dart';
import 'pages/Search.dart';
import 'pages/Form.dart';
import 'pages/user/Login.dart';
import 'pages/user/Register.dart';
import 'pages/user/Register2.dart';
import 'pages/AppBarDemo.dart';
import 'pages/TabBarController.dart';
import 'pages/MyButton.dart';
import 'pages/MyCheckBox.dart';
import 'pages/MyRadio.dart';
import 'pages/MyDate.dart';
import 'pages/MySwiper.dart';
import 'pages/MyDialog.dart';
import 'pages/MyTextField.dart';

// 配置路由
final routes = {
  '/myButton': (context,{arguments}) => MyButton(),
  '/': (context,{arguments}) => HomeBottomTabs(),
  '/appBarDemo': (context,{arguments}) => AppBarDemo(),
  '/search': (context,{arguments}) => SearchPage(arguments: arguments),
  '/form': (context, {arguments}) => FormPage(arguments: arguments),
  '/login': (context, {arguments}) => LoginPage(),
  '/register': (context, {arguments}) => RegisterPage(),
  '/register2': (context, {arguments}) => Register2Page(),
  '/tabBarController': (context, {arguments}) => TabBarControllerPage(),
  '/myTextField': (context,{arguments}) => MyTextField(),
  '/myCheckBox': (context,{arguments}) => MyCheckBox(),
  '/myRadio': (context, {arguments}) => MyRadio(),
  '/myDate': (context,{arguments}) => MyDate(),
  '/mySwiper': (context,{arguments}) => MySwiper(),
  '/myDialog': (context,{arguments}) => MyDialog(),
};

// 固定写法
Function onGenerateRoute = (RouteSettings settings){
    // 统一处理
    final String name = settings.name;
    final Function pageContentBuilder = routes[name];
    if (pageContentBuilder != null) {
        if (settings.arguments != null) {
          final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context, arguments: settings.arguments)
          );
          return route;
        } else {
          final Route route = MaterialPageRoute(
              builder: (context) => pageContentBuilder(context)
          );
          return route;
        }
      }
};